package com.atguigu.oshi.demos.controller;

import com.atguigu.oshi.demos.common.R;
import com.atguigu.oshi.demos.service.CpuLoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: oshi
 * @description:
 * @author: Mr.Yan
 * @create: 2024-12-08 16:31
 **/
@RequestMapping("/metrics")
@RestController
@CrossOrigin
public class CpuLoadRestController {
@Autowired
 CpuLoadService cpuLoadService;

@GetMapping("/cpuload")
//对接前端的R，返回json数据，不用管泛型，对接后端远程调用需要泛型
public R getCpuLoad() {
 double[] cpuLoad = cpuLoadService.getCpuLoad();
 return R.ok(cpuLoad);
}
}
